


import * as echarts from 'echarts'
export default {
  methods: {
    GaugeChart_V2Init(v){
      const gaugeSeries = [
        {
          value: 50,
          name: 'SCORE',
        },
      ]

      let echartEle=  this.$refs[v];
      let myChart = echarts.init(echartEle);

      const {
        dataSourceType,options,staticData
      } = this.controlProperties[v]

      if (dataSourceType === 'static' && Object.keys(staticData).length) {
        options.series = options.series.map((item, index) => {
          return { ...item, data: staticData.series[index].data }
        })
      } else if(dataSourceType === 'static' && !Object.keys(staticData).length){
        options.series = options.series.map((item, index) => {
          return { ...item, data: gaugeSeries }
        })
      }

      options && myChart.setOption(options);
     },
     GaugeChart_V2SetOption(v){
        const { options,seriesType,flowResult } = this.controlProperties[v]
        let {  series } = options
       
        // series
        series = series.map((item) => {
          item.data = flowResult[item.dataSource[item.dataSource.length - 1].dataKey]
        })
        let echartEle=  this.$refs[v];
        let myChart = echarts.init(echartEle);
        options && myChart.setOption(options);
     },
   }
  }
